package com.hailong.hadoop.rpc.protobuf;


import com.hailong.hadoop.rpc.protobuf.proto.MyResourceTrackerMessage;

/**
 * Created by yuanhailong on 2022/1/11.
 */
public class MyResourceTrackerService implements MyResourceTracker {

    @Override
    public MyResourceTrackerMessage.MyRegisterNodeManagerResponseProto registerNodeManager(MyResourceTrackerMessage.MyRegisterNodeManagerRequestProto request) throws Exception {

        MyResourceTrackerMessage.MyRegisterNodeManagerResponseProto.Builder builder=
                MyResourceTrackerMessage.MyRegisterNodeManagerResponseProto.newBuilder();

        String hostname = request.getHostname();
        int cpu = request.getCpu();
        int memory = request.getMemory();

        System.out.println("NodeManager 注册消息: hostname:"+hostname +"   cpu:"+cpu+"    memory:"+memory);

        builder.setFlag("注册成功");
        MyResourceTrackerMessage.MyRegisterNodeManagerResponseProto response = builder.build();

        return response;
    }
}
